package com.lccviolet;

import java.util.concurrent.CountDownLatch;

/**
 * @author LiChaochao
 * @Date 2021/9/9 16:07
 * @Description CountDownLatchDemo
 */
public class CountDownLatchDemo {

    public static void main(String[] args) throws InterruptedException {

        CountDownLatch countDownLatch = new CountDownLatch(5);

        for (int i = 1; i <= 5; i++) {
            new Thread(() -> {
                System.out.println(Thread.currentThread().getName() + "离开教室");
                countDownLatch.countDown();
            }, CountryEnum.forEach_CountryEnum(i).getRetMessage()).start();
        }

        // 从这里开始等待，直到CountDownLatch构造中的数减为0，才能继续向下执行
        countDownLatch.await();
        System.out.println(Thread.currentThread().getName() + "。。。。。。离开教室");
    }
}
